require(["../../conf/config.js"],()=>{
	require(["jquery"],function($){
		let res=[];
		$("#Phone_Mobile").blur(function(){
			console.log(1);
			if (/^(13|15|17|18)\d{9}$/.test($("#Phone_Mobile").val())) {
				res[0]=true;
				$(".pass-error1").css({"display":"none"});
			}
			else{
				res[0]=false;
				$(".pass-error1").css({"display":"inline-block"});
				
			}
			if(document.cookie.indexOf($("#Phone_Mobile").val()) != -1 && $("#Phone_Mobile").val() != ""){
				res[1] = false;
				$(".pass-error3").css({"display":"inline-block"});
			} else {
				
				res[1] = true;
				$(".pass-error3").css({"display":"none"});
			}
		})
		// $("#Phone_Password").blur(function(){
		// 	console.log(1);
		// 	if ($("#Phone_Password").val()=="") {
		// 		res[1]=true;
		// 		$(".pass-tip").css({"display":"none"});
		// 	}
		// 	else{
		// 		res[1]=false;
		// 		$(".pass-tip").css({"display":"inline-block"});
		// 		
		// 	}
		// })
		$("#Phone_Password").blur(function(){
			console.log(1);
			if (/^.{6,}$/.test($("#Phone_Password").val())) {
				res[2]=true;
				$(".pass-error2").css({"display":"none"});
			}
			else{
				res[2]=false;
				$(".pass-error2").css({"display":"inline-block"});
				
			}
		})
		$("#Phone_Password").blur(function(){
			console.log(1);
			if (/^[a-zA-Z0-9]{6,20}$/.test($("#Phone_Password").val())) {
				res[3]=true;
				$(".pass-succ").css({"display":"inline-block"});
			}
			else{
				res[3]=false;
				$(".pass-succ").css({"display":"none"});
				
			}
		})
		$(".btn-green-l").click(function(){
			console.log(2);
			let now = new Date();
			now.setDate(now.getDate() + 10);
			if(res.length<4){
				alert("请先完善注册信息")
			} else {
				let result = res.every(function(item){
					return item == true;
				})
				if(result){
					let Num = Math.random()*10000;
					document.cookie = "username" + Num +"=" + $("#Phone_Mobile").val() + "; expires = " + now;
					document.cookie = "password" + Num +"=" + $("#Phone_Password").val() + "; expires = " + now;
					alert("注册成功")
				} else {
					alert("输入信息有误，请认真阅读填写要求")
				}
			}
		})
	}) 
})